import request from "../../untils/request"

export function getLastLog() {
    return request({
        url: "http://localhost:8090/camera/getLastLog",
        method: "get"
    })
}

export function getLogs() {
    return request({
        url: "http://localhost:8090/camera/getLogs",
        method: "get"
    })
}

export function getOnlineNum() {
    return request({
        url: "http://localhost:8090/camera/getOnlineNum",
        method: "get"
    })
}

export function startVideoLive(ipAddress, rtspUrl) {
  var webRtcServer = null;
      //页面加载时加载视频画面,请先打开webrtc服务
    window.onload = function() {
            //video：需要绑定的video控件ID
            //启动webrtc-streamer的设备IP——工控机的ip

            webRtcServer = new WebRtcStreamer("videoLive", "http://" + '127.0.0.1' + ":8000/");
            //需要查看的rtsp地址
            webRtcServer.connect(rtspUrl);
        }
        //页面退出时销毁
    window.onbeforeunload = function() {
        webRtcServer.disconnect();
    }
}

export function restartVideoLive(ipAddress, rtspUrl) {

    var webRtcServer = new WebRtcStreamer("videoLive", "http://" + '127.0.0.1' + ":8000/");
    webRtcServer.disconnect();
    webRtcServer.connect(rtspUrl);

}